package com.magicalcoder.pigeon.ioc;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by hzhedongyu on 2017/6/15.
 */
public class PigeonBeanContainer {

    private static Map<String,Object> beanMap = new HashMap<String,Object>();
    private static Map<String,String> clazzValueMap = new HashMap<String,String>();


    static void addMap(Map<String,Object> addBeanMap,Map<String,String> addClazzValueMap){
        beanMap.putAll(addBeanMap);
        clazzValueMap.putAll(addClazzValueMap);
    }

    /**
     *
     * @param clazz 实现类 返回接口 UserServiceImpl.class
     * @param <T>
     * @return UserService
     */
    public static <T> T getBean(Class<? extends T> clazz){
        return (T)beanMap.get(clazzValueMap.get(clazz.getName()));
    }

}
